home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 26 / macformat_26.iso / Los 50 mejores / Mejoras del sistema / Smart Scroll / for Developers / LScroller.cp example < prev    next >
Text File  |  1996-09-23  |  2KB  |  86 lines

  1. /*
  2.     Below is an example of adding "Smart Scrolling" to the PowerPlant LScroller.cp
  3.  
  4.     The SetSmartScrollInfo call gives the Smart Scroll INIT the info it needs
  5.     to accurately show which proportion of your document is visible. 
  6.  
  7.     note: More examples and a real documentation are coming...
  8.     Please email me at Marc@Kagi.com, and I'll help as much as I can
  9.     to add this feature to your products!
  10.     
  11. */
  12.  
  13. // ===========================================================================
  14. //    LScroller.cp               ©1993-1996 Metrowerks Inc. All rights reserved.
  15. // ===========================================================================
  16. //
  17. //    A Scroller controls the position of another View and may have a
  18. //    horizontal and/or vertical scroll bar
  19.  
  20. /* <--snip--> */
  21.  
  22. // ---------------------------------------------------------------------------
  23. //        • DrawSelf
  24. // ---------------------------------------------------------------------------
  25. //    Draw a Scroller
  26.  
  27. void
  28. LScroller::DrawSelf()
  29. {
  30.     Rect    frame;                    // Scroller has a one pixel border
  31.     CalcLocalFrameRect(frame);
  32.     ::PenNormal();
  33.     ApplyForeAndBackColors();
  34.     ::FrameRect(&frame);
  35.     
  36.     /*msy*/
  37.     if (mVerticalBar != nil) {
  38.         MoveTo(frame.right - 16, frame.top);
  39.         LineTo(frame.right - 16, frame.bottom - 1);
  40.         SDimension32  imag;
  41.         mScrollingView->GetImageSize(imag);
  42.         SDimension16    frm;
  43.         mScrollingView->GetFrameSize(frm);
  44.         SetSmartScrollInfo (mVerticalBar->GetMacControl(),     (long) frm.height ,
  45.                                                              (long) imag.height);
  46.     }
  47.     
  48.     if (mHorizontalBar != nil) {
  49.         MoveTo(frame.left, frame.bottom - 16);
  50.         LineTo(frame.right - 1, frame.bottom - 16);
  51.         SDimension32  imag;
  52.         mScrollingView->GetImageSize(imag);
  53.         SDimension16    frm;
  54.         mScrollingView->GetFrameSize(frm);
  55.         SetSmartScrollInfo (mHorizontalBar->GetMacControl(),     (long) frm.width ,
  56.                                                                  (long) imag.width );
  57.     }
  58.         // When inactive, ScrollBars are hidden. Just outline
  59.         // the ScrollBar locations with one pixel borders.
  60.     
  61.     if (!IsActive()) {
  62.         if (mVerticalBar != nil) {
  63.             mVerticalBar->CalcPortFrameRect(frame);
  64.             PortToLocalPoint(topLeft(frame));
  65.             PortToLocalPoint(botRight(frame));
  66.             ::FrameRect(&frame);
  67.             ::InsetRect(&frame, 1, 1);
  68.             ::EraseRect(&frame);
  69.         }
  70.  
  71.         if (mHorizontalBar != nil) {
  72.             mHorizontalBar->CalcPortFrameRect(frame);
  73.             PortToLocalPoint(topLeft(frame));
  74.             PortToLocalPoint(botRight(frame));
  75.             ::FrameRect(&frame);
  76.             ::InsetRect(&frame, 1, 1);
  77.             ::EraseRect(&frame);
  78.         }
  79.     }
  80. }
  81.  
  82.  
  83.  
  84. /* <--snip--> */
  85.  
  86.